package cate.game.fight.msg;

import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBFight;
import cate.game.play.proce.play.PlayPO;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

@ClientMsg(title = "战斗录像 の 请求")
public class FightReplayReq implements MsgInput {

    @NoteField("剧本uid")
    public String replayUid;

    @Override
    public MsgConfig conf() {
        return MsgIdBFight.REPLAY_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        if(StringUtils.isBlank(replayUid)){
            game.notice.message(cc.getRole(), "录像已过期");
            return;
        }
        //暂时支持本服录像
        PlayPO play = game.facilities.getMongo().play.findById(replayUid).orElse(null);
        if (play == null) {
            game.notice.message(cc.getRole(), "录像已过期");
            return;
        }
        cc.getRole().sendNow(new FightReplayResp(play));
    }
}
